/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.hitechbangla.fctu.training;

import com.hitechbangla.fctu.base.aircraft.Aircraft;
import java.util.Timer;

/**
 *
 * @author InspireServe
 */
public class NinetyDegreeAttack extends CGITask{

    @Override
    public void run() {
        //super.run(); //To change body of generated methods, choose Tools | Templates.
        //System.out.println("Executing cgi task");
        NinetyDegreeAttack nda;
        switch(phase){
            
            case 0:
                //worker.cancel();
                //System.out.println("in case "+phase);
                
                String commandForTarget = target.getAircraftState().getCallSign()+targetCommands[phase];
                //String commandForTarget = target.getAircraftState().getCallSign() + "tl270";
                //System.out.println(commandForTarget);
                target.executeCommand(commandForTarget);
                
                 String commandForInterceptor = interCeptor.getAircraftState().getCallSign()+interceptorCommands[phase];
                //String commandForInterceptor = interCeptor.getAircraftState().getCallSign()+"tr090";
                //System.out.println(commandForInterceptor);
                interCeptor.executeCommand(commandForInterceptor);
                
                
                
//                //String commandForInterceptor = interCeptor.getAircraftState().getCallSign()+interceptorCommands[phase];
//                String commandForInterceptor = interCeptor.getAircraftState().getCallSign()+"tr090";
//                //System.out.println(commandForInterceptor);
//                interCeptor.executeCommand(commandForInterceptor);
                
                //nda = new NinetyDegreeAttack(this);
                //worker.schedule(nda, 5000);
                break;
                
            case 1:
                //System.out.println("in case "+phase);
                
                //String commandForTarget2 = target.getAircraftState().getCallSign()+targetCommands[phase];
                String commandForTarget2 = target.getAircraftState().getCallSign()+"tr360";
                //String commandForTarget2 = target.getAircraftState().getCallSign() + "tl180";
                //System.out.println(commandForTarget2);
                target.executeCommand(commandForTarget2);
                
                //String commandForInterceptor2 = interCeptor.getAircraftState().getCallSign()+interceptorCommands[phase];
                String commandForInterceptor2 = interCeptor.getAircraftState().getCallSign()+"tr180";
                //System.out.println(commandForInterceptor2);
                interCeptor.executeCommand(commandForInterceptor2);
                
                //nda = new NinetyDegreeAttack(this);
                //worker.cancel();
               // worker.schedule(nda, 2000);
                break;
                
            case 2:
                //printf("in case 2");
                //n = new NinetyDegreeAttack(this);
                //worker.schedule(n, 5000);
                //System.out.println("in case "+phase);
                
                //String commandForTarget3 = target.getAircraftState().getCallSign()+targetCommands[phase];
                String commandForTarget3 = target.getAircraftState().getCallSign()+"tr090";
                //System.out.println(commandForTarget3);
                target.executeCommand(commandForTarget3);
                
                //String commandForInterceptor3 = interCeptor.getAircraftState().getCallSign()+interceptorCommands[phase];
                String commandForInterceptor3 = interCeptor.getAircraftState().getCallSign()+"tr270";
                //System.out.println(commandForInterceptor3);
                interCeptor.executeCommand(commandForInterceptor3);
                
               // nda = new NinetyDegreeAttack(this);
                //worker.cancel();
               // worker.schedule(nda, 3000);
                break;
                
            case 3:
                //System.out.println("in case "+phase);
                
                //String commandForInterceptor4 = interCeptor.getAircraftState().getCallSign()+interceptorCommands[phase];
                String commandForInterceptor4 = interCeptor.getAircraftState().getCallSign()+"tr360";
                //System.out.println(commandForInterceptor4);
                interCeptor.executeCommand(commandForInterceptor4);
                break;
        }
    }

    public NinetyDegreeAttack(Timer t) {
        super(t);
    }
    
    //first constcrutor
    public NinetyDegreeAttack(Aircraft target, Aircraft interceptor, Timer t){
        super(target, interceptor, t);
        
        targetCommands = new String[3];
        targetCommands[0] = "tl270";
        targetCommands[1] = "tr360";
        targetCommands[2] = "tr090";
        
        interceptorCommands = new String[4];
        interceptorCommands[0] = "tr090";
        interceptorCommands[1] = "tr180";
        interceptorCommands[2] = "tr270";
        interceptorCommands[3] = "tr360";
        
        taskStartTime = new int[4];
        taskStartTime[0] = 10;
        taskStartTime[1] = 4;
        taskStartTime[2] = 6;
        taskStartTime[3] = 6;
        //command = sl090
    }
    
    public NinetyDegreeAttack(NinetyDegreeAttack attack){
        super(attack);
    }
    
}//end of class

